package com.yidu.view;

import com.google.gson.Gson;
import com.yidu.dao.TStudentMapper;
import com.yidu.dao.TeacherMapper;
import com.yidu.domain.TClass;
import com.yidu.domain.TStudent;
import com.yidu.domain.Teacher;
import com.yidu.utils.SqlSessionTools;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>@Description: No Description</p>
 * <p>@Author yidu-liandyao</p>
 * <p>@Date: 2021-01-06</p>
 * <p>@Time: 10:06</p>
 */
public class TStudentTest {
    @Test
    public void selectAll(){
        /**
         * org.apache.ibatis.binding.BindingException: Type interface com.yidu.dao.TeacherMapper is not known to the MapperRegistry.
         */
        SqlSession session = SqlSessionTools.getSession();
        TStudentMapper mapper = session.getMapper(TStudentMapper.class);
        StudentVo vo = new StudentVo();
        vo.setStuName("java");

        vo.setPage(0);
        vo.setLimit(100);
        List<TStudent> list = mapper.findAll(vo);
        Gson gson = new Gson();
        System.out.println(gson.toJson(list));

        session.close();
    }

    @Test
    public void delete(){
        SqlSession session = SqlSessionTools.getSession();
        TStudentMapper mapper = session.getMapper(TStudentMapper.class);

        Integer[] arr= {5,6,8};
        mapper.deleteBatch(arr);
    }

    @Test
    public void selectName(){
        /**
         * org.apache.ibatis.binding.BindingException: Type interface com.yidu.dao.TeacherMapper is not known to the MapperRegistry.
         */
        SqlSession session = SqlSessionTools.getSession();
        TStudentMapper mapper = session.getMapper(TStudentMapper.class);

        List li=new ArrayList();
        li.add("李四");
        li.add("张三");

        List<TStudent> list = mapper.selectByName(li);
        Gson gson = new Gson();
        System.out.println(gson.toJson(list));

        session.close();
    }

}
